<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <title>City Press</title>
        <link rel="stylesheet" href="#{request.contextPath}/themes/ui-lightness/skin.css" />
    </h:head>
    <h:body>


        <p:layout fullPage="true">  

            <p:layoutUnit id="top" position="top" height="150"  resizable="false" closable="false" collapsible="false">  


            </p:layoutUnit>  

            <p:layoutUnit position="bottom" height="125" resizable="false" closable="false" collapsible="false">  


                <p:dock>  
                    <p:menuitem onclick="dlg.show()" icon="/images/login.jpg" url="#"/>
                    <p:menuitem value="Register" icon="/images/register.jpg" url="#"/>  
                    <p:menuitem value="Search" icon="/images/search.jpg" url="#"/>   
                </p:dock>

            </p:layoutUnit>  

            <p:layoutUnit position="left" width="200"  resizable="false" closable="false" collapsible="false">  
                <ol>
                    <li><a href="faces/browseArticles.xhtml">Browse Articles</a></li>
                    <li><a href="faces/search.xhtml">Search </a></li>
                    <li><a href="faces/viewLatestArticles.xhtml">View latest Articles</a></li>
                    <li><a href="faces/viewLatestComments.xhtml">View latest Comments</a></li>
                </ol>
                <ol>
                    <li><a href="faces/login.xhtml">Login</a></li>
                    <li><a href="faces/register.xhtml">Register</a></li>
                </ol>
            </p:layoutUnit>  

            <p:layoutUnit position="right" width="200" resizable="false" closable="false" collapsible="false">  

            </p:layoutUnit>  

            <p:layoutUnit position="center">  

            </p:layoutUnit>  

        </p:layout>  



        <p:growl id="growl" showDetail="true" life="3000" /> 
        <p:dialog id="dialogLogin" header="Login" widgetVar="dlg" showEffect="fade" hideEffect="fade">  
            <h:form>  
                <h:panelGrid columns="2" cellpadding="5">  
                    <h:outputLabel for="username" value="Username: *" />  
                    <p:inputText value="#{loginBean.username}"   
                                 id="username" required="true" label="username" />  
                    <h:outputLabel for="password" value="Password: * " />  
                    <h:inputSecret value="#{loginBean.password}"   
                                   id="password" required="true" label="password" />  
                    <f:facet name="footer">  
                        <p:commandButton value="Login" update="growl"   
                                         actionListener="#{loginBean.loginUser()}"   
                                         oncomplete="handleLoginRequest(xhr, status, args)"/>  
                    </f:facet>  
                </h:panelGrid>  
            </h:form>  
        </p:dialog>

        <p:dialog id="dialogRegistration" header="Registration" widgetVar="dreg" showEffect="fade" hideEffect="fade">
            <h:form id="registrationForm"> 
                <hr></hr>
                <h:messages/>
                <fieldset>
                    <h:outputLabel for="name" value="Name:"/>
                    <h:inputText value="#{registrationBean.registeredUser.name}" id="name" required="true"/>
                    <h:message for="name"/>
                    <br/>
                    <h:outputLabel for="surname" value="Surname(*):"/>
                    <h:inputText value="#{registrationBean.registeredUser.surname}" id="surname" required="true"/>
                    <h:message for="surname"/>
                    <br/>
                    <h:outputLabel for="username" value="Username(*):"/>
                    <h:inputText id="username" value="#{registrationBean.registeredUser.username}" required="true"/>
                    <h:message for="username"/>
                    <br/>
                    <h:outputLabel for="password" value="Password(*):"/>
                    <h:inputSecret id="password" value="#{registrationBean.registeredUser.password}" required="true"/>
                    <h:message for="password"/>
                    <br/>
                    <h:outputLabel for="email" value="Email(*):"/>
                    <h:inputText id="email" value="#{registrationBean.registeredUser.email}" required="true"/>
                    <h:message for="email"/>
                    <br/>
                    <h:selectOneRadio id="sor" value="#{registrationBean.registeredUser.userType}" 
                                      title="Please choose a user type" layout="pageDirection" border="1">
                        <f:selectItem id="ut1"   itemLabel="Student" itemValue="student" />
                        <f:selectItem id="ut22"  itemLabel="lecturer" itemValue="lecturer" />
                        <f:selectItem id="ut3"   itemLabel="Other academic staff" itemValue="other academic staff" />
                    </h:selectOneRadio>
                    <br/>                  
                    <h:outputLabel for="steetName" value="Street Name(*):"/>
                    <h:inputText id="streetName" value="#{registrationBean.registeredUser.streetName}" required="true"/>
                    <h:message for="streetName"/>
                    <br/>
                    <h:outputLabel for="zip" value="Zip(*):"/>
                    <h:inputText id="zip" value="#{registrationBean.registeredUser.zip}" required="true"/>
                    <h:message for="zip"/>
                    <br/>
                    <h:outputLabel for="website" value="Website:"/>
                    <h:inputText id="website" value="#{registrationBean.registeredUser.website}"/>
                    <h:message for="website"/>
                </fieldset>
                <hr></hr>
                <h:commandButton value="Register" action="#{registrationBean.persistRegisteredUser}"/>
                <h:commandButton value="Cancel" action="showIndex"></h:commandButton>
                <hr> </hr>
            </h:form>
        </p:dialog>

        <script type="text/javascript">  
            function handleLoginRequest(xhr, status, args) {  
                if(args.validationFailed || !args.loggedIn) {  
                    jQuery('#dialog').parent().effect("shake", { times:3 }, 100);  
                } else {  
                    dlg.hide();  
                    jQuery('#loginLink').fadeOut();  
                }  
            }  
        </script> 
    </h:body>
</html>

